﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TasksModel
{
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://mp.tasks.com/2010/")]
    public class TaskFlagList : TaskObservableCollection<TaskFlag>
    {
        public TaskFlagList()
        {
        }

        public TaskFlagList(TaskFlagList list)
            : base(list)
        {
        }

        public TaskFlagList Sort<TKey>(Func<TaskFlag, TKey> keySelector)
        {
            IOrderedEnumerable<TaskFlag> o = this.OrderBy(keySelector);
            int i = 0;
            SuspendChangedEvents();
            foreach (TaskFlag s in o)
            {
                Move(IndexOf(s), i);
                i++;
            }
            ResumeChangedEvents();
            return this;
        }

        public void SetupDefault()
        {
            Clear();
            Add(new TaskFlag(new Guid("00000000000000009999999977777781"))
            {
                RGBColor = 0x00FF0000,
                Name = "Red"
            });
            Add(new TaskFlag(new Guid("00000000000000009999999977777782"))
            {
                RGBColor = 0x000000FF,
                Name = "Blue"
            });
            Add(new TaskFlag(new Guid("00000000000000009999999977777783"))
            {
                RGBColor = 0x0000FF00,
                Name = "Green"
            });
            Add(new TaskFlag(new Guid("00000000000000009999999977777784"))
            {
                RGBColor = 0x00FFA500,
                Name = "Orange"
            });
            Add(new TaskFlag(new Guid("00000000000000009999999977777785"))
            {
                RGBColor = 0x00A020F0,
                Name = "Purple"
            });
            Add(new TaskFlag(new Guid("00000000000000009999999977777786"))
            {
                RGBColor = 0x00FFFF00,
                Name = "Yellow"
            });
        }
    }
}